package com.harr.noddles.crawler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/crawler")
public class Api {
	
    private final CrawlerService crawlerService;

	@Autowired
	public Api(CrawlerService crawlerService) {
		this.crawlerService = crawlerService;
	}

	@GetMapping("/status")
	public CrawlerMetrics status() {
		return crawlerService.status();
	}
	
	@GetMapping("/start")
	public void start() {
		crawlerService.start();
	}
	
	@GetMapping("/stop")
	public void stop() {
		crawlerService.stop();
	}
}
